r = input("Введите последовательность скобок ")

def cl(s):
    d = "".join(set(s))
    d = d.replace("<","").replace(">","").replace("(","").replace(")","").replace("[","").replace("]","").replace("{","").replace("}","")

    for i in d:
        s=s.replace(i,"")
    return(s)
print(cl(r))
s = input()
def killer(zu):
    for i in range(1000):
        zu = zu.replace("()","")
    if len(zu)>0:
        return False
    else:
        return True
print(killer(s))
